package com.wa.handler;

import com.corundumstudio.socketio.AckRequest;
import com.corundumstudio.socketio.SocketIOClient;
import com.corundumstudio.socketio.SocketIOServer;
import com.corundumstudio.socketio.listener.DataListener;
import com.wa.constants.WebSocketEventConstant;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author recharde.li@allchips.com
 * @version V1.0
 * @date 2020-05-28 11:22
 **/
@Component
public class WebSocketCommonMessageEventHandler<T> implements DataListener<T> {

    @Resource
    private SocketIOServer socketIOServer;

    @Override
    public void onData(SocketIOClient socketIOClient, T o, AckRequest ackRequest) throws Exception {
        socketIOClient.sendEvent(WebSocketEventConstant.MESSAGE_EVENT, o);
    }

}
